package laravel.mvc.view.route;

import node.Node;
import node.TextNode;

/**
 * Created by thormentor on 29-04-2014.
 */
public class Route extends Node implements IRouteElement{
    private final Method method;
    private final String path;

    public Route(Method method, String path, String as, String uses) {
        this.method = method;
        this.path = path;
        appendChild(new TextNode("'as' => '" + as + "',"));
        appendChild(new TextNode("'uses' => '" + uses + "'"));
    }

    @Override
    protected String getBegin() {
        return "Route::" + method + "('" + path + "', array(";
    }

    @Override
    protected String getEnd() {
        return "));";
    }

    public enum Method {
        GET, POST;

        @Override
        public String toString() {
            return super.toString().toLowerCase();
        }
    }
}
